Repository navigation
Conversation
|
For discussion: maybe we need a feature flag for that |
|
Hi @sylvestre , Is it OK for you? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2777 +/- ##
==========================================
+ Coverage 80.68% 80.80% +0.11%
==========================================
Files 78 78
Lines 48610 48999 +389
==========================================
+ Hits 39223 39595 +372
- Misses 9387 9404 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
974dbe8 to
9ba6fa7
Compare
|
@AJIOB thanks for looking at this. Yes, it covers #2745 directly and should also resolve #2700. #2745 asks for the retry-locally behaviour plus visibility, and both are here: the fallback is logged at info (which server, and why it fell back) with the remote's stderr at debug, and the failure is already counted as On the feature flag: I defaulted it to on because the alternative is a hard build failure for something sccache can recover from, which is what #2745 is asking to avoid. The counter-argument I see is CI, where you might prefer a loud failure over silently slower local builds masking a broken cluster. I am happy to add an opt-out for that, either a On the red dist-tests: that failure was pre-existing on the base I branched from, not from this change. main at 7cd4f2c fails the same two tests with no patches applied ( |
9ba6fa7 to
257f543
Compare
257f543 to
9f2d002
Compare
|
@AJIOB the flag is in: a |
909138a to
8d47f8e
Compare
sccache logged the distribute-vs-local decision only at debug ("Compiling
locally", "Attempting distributed compilation"), while an infrastructure
fallback warned. At info a successful distribution and a local compile were
both silent, so the only visible dist signal was the failure path - leaving
no way to see the distribute/fallback ratio without the full debug firehose.
Diagnosing why a distributed build under-distributes meant guessing.
Promote the decision points to info and add a log on successful
distribution naming the server and exit code, so SCCACHE_LOG=info gives a
per-compile dist trace (attempt then distributed-on-server, compiled-locally,
or falling-back-with-reason). sccache only emits logs when SCCACHE_LOG is
set, so default runs are unaffected.
Signed-off-by: Javier Tia <javier@peridio.com>
A distributed compile the build-server rejects is often a distribution artifact, not a genuine compiler error: an object that .incbin's a binary the inputs packager does not ship - the kernel's vdso, embedded-config, and dtb wrappers - cannot be assembled remotely and returns non-zero, which failed the whole build with no recourse and forced the kernel to be excluded wholesale. Treat a non-zero remote result as a fallback trigger rather than a terminal error: recompile locally, which either succeeds (confirming a dist-only artifact) or reproduces the genuine error. A remote failure can no longer break a build that would compile locally. Only failing dist compiles are affected - successful ones are returned unchanged - so the kernel now distributes (1124/1128 compiles), with its handful of .incbin objects falling back to local. Signed-off-by: Javier Tia <javier@peridio.com>
A distributed compile can return a successful (exit 0) result yet omit a
declared output. glibc's ldconfig.o and sprof.o compile fine on the
build-server, but it does not return their `.o.dt` dependency file, so zipping
the compiler outputs fails fatally ("failed to open file ...o.dt: No such file")
with no recourse. One dropped output among 6427 forced glibc to be excluded from
distribution wholesale, even though 6425 of its compiles distribute cleanly.
Capture the declared output paths before the compilation is moved into the
packagers, and after a successful remote compile verify each one exists on disk.
A missing output is a distribution artifact, not a compiler error, so bail into
the existing local-recompile fallback (the same one that already salvages
non-zero remote results), which reproduces the full output set. Only compiles
whose dist output set is incomplete are affected; complete ones are returned
unchanged. glibc now distributes, with ldconfig.o and sprof.o falling back to
local.
Signed-off-by: Javier Tia <javier@peridio.com>
When sccache runs as a compiler wrapper (`sccache <compiler> ...`) it
shares stderr with the wrapped compiler. A build's feature probes treat
any unexpected stderr as a compiler failure: libtool's -fPIC check
(_LT_COMPILER_OPTION) sets pic_flag="" whenever the probe compile emits
stderr, even on exit 0. With SCCACHE_LOG set, the client's own
env_logger records ("Attempting to read config file", "Server sent
CompileStarted") landed on that shared stderr, so an autotools package
configured with pic_flag="" and produced non-PIC objects that failed to
link into a shared library (relocation R_X86_64_32 ... recompile with
-fPIC). It looked concurrency-dependent because the client's startup
logging varies with server-connection timing, so the probe stderr only
sometimes diverged from libtool's expected boilerplate.
Initialize logging after parsing the command so the compile-wrapper case
can choose its target: route sccache's own records to SCCACHE_ERROR_LOG
when set, keep stderr only when it is an interactive terminal (so
`SCCACHE_LOG=debug sccache gcc ...` at a prompt still shows logs), and
discard them when stderr is captured by a build. The wrapped compiler's
forwarded stderr is untouched.
Signed-off-by: Javier Tia <javier@peridio.com>
When a distributed compile exits non-zero the client logs only the exit code and falls back to a local recompile, discarding the remote compiler's stdout and stderr. That output is the only place the actual failure is visible - a missing target std, an input the packager did not ship, a sandbox path that does not resolve - so diagnosing a dist regression meant patching in a temporary dump and rebuilding the binary each time. Emit the remote stdout/stderr at debug on the non-zero path. SCCACHE_LOG=debug now surfaces the real remote error with no rebuild, while a normal SCCACHE_LOG=info run stays quiet (the one-line fallback reason is still logged at warn by the caller). Signed-off-by: Javier Tia <floss@jetm.me> Signed-off-by: Javier Tia <javier@peridio.com>
Kernel assembler sources that .incbin generated files fail on the build server, because the generated file is not among the shipped inputs. Upstream 0.19.0 reports that remote exit code to the client as the result of the compile. The fork needs the opposite: the client recompiles such a unit locally, so the kernel build still completes. The two behaviours cannot share one code path without one of the upstream remote-exit-code tests losing its assertions. Add a boolean key `fallback` to the [dist] section of the client configuration. It defaults to true, which keeps the fork behaviour, and false selects the upstream 0.19.0 behaviour. This commit adds only the key, its documentation and a unit test parsing both the explicit value and the default; the compiler honors the key in the next commit. Because unknown keys are denied, an older binary rejects a configuration that contains the key, which the documentation states. Signed-off-by: Javier Tia <floss@jetm.me> Signed-off-by: Javier Tia <javier@peridio.com>
A non-zero remote exit code or a missing declared output unconditionally triggered a local recompile. That contradicts upstream's behaviour, where the remote result reaches the client with its exit code and stderr, and it contradicts upstream's test for that case. Both bails in the dist compile path now consult the `[dist] fallback` key through a provided DistClient method, defaulting to true so the kernel build keeps recompiling locally. With false the remote result is returned as release 0.19.0 does. The HTTP client carries the value from the dist configuration; test clients override it. Upstream's failed compile test and its docker-based integration twin keep every assertion and run with fallback false, and two new tests cover both modes. Signed-off-by: Javier Tia <floss@jetm.me>
…mpile After a successful remote compile the client fell back to a local recompile only when a declared output path did not exist. A stale object from an earlier build sits at that path, so a server that dropped the output still passed the check and the stale file was cached as the result of the new compile. Match each declared output against the set the server returned. gcc's dependency file is the exception: the local preprocessor writes it and the server never returns it, so it keeps the existence check. Without that exemption every -MD compile would fall back locally. Signed-off-by: Javier Tia <javier@peridio.com>
8d47f8e to
1178a21
Compare
| // Logging is initialized after parsing so the compile-wrapper case can keep | ||
| // sccache's own log records off the wrapped compiler's stderr. | ||
| init_logging(&command); | ||
|
|
There was a problem hiding this comment.
this is unrelated to the fallback, please split it into its own PR
| @@ -126,6 +128,35 @@ fn init_logging() { | |||
| builder.format_timestamp_millis(); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
so SCCACHE_LOG=debug in CI or under make now prints nothing at all?
the user explicitly asked for these logs, discarding them silently seems wrong
| @@ -126,6 +128,35 @@ fn init_logging() { | |||
| builder.format_timestamp_millis(); | |||
There was a problem hiding this comment.
if the log file can't be opened, we silently drop everything?
commands.rs bails in that case
| debug!("[{}]: Compiling locally", out_pretty); | ||
| info!( | ||
| "[{}]: Compiling locally (not eligible for distributed compilation)", | ||
| out_pretty |
There was a problem hiding this comment.
this is logged at info on every compile, including for people without dist configured
and "not eligible" is wrong when there is simply no dist client
please keep it at debug
| .collect::<Option<_>>() | ||
| .context("Failed to adapt an output path for distributed compile")?; | ||
| // The local paths every declared output must occupy once the compile | ||
| // finishes. Captured before `compilation` is moved into the packagers |
There was a problem hiding this comment.
nobody will read such a long comment :)
please make it shorter (same for the ones at the bail! below)
| path_transformer | ||
| .as_dist_abs(&local) | ||
| .map(|dist| (dist, local, output.key == "d")) | ||
| }) |
There was a problem hiding this comment.
matching on the key "d" feels fragile, does it hold for nvcc/nvhpc too?
could the output carry this information instead?
| @@ -4261,6 +4654,137 @@ mod test_dist { | |||
| fn rewrite_includes_only(&self) -> bool { | |||
There was a problem hiding this comment.
this is almost a copy of OneshotClient, could be dedup, no?
new and dropping are also the same code twice
| @@ -46,6 +46,12 @@ scheduler_url = "http://1.2.3.4:10600" | |||
| toolchains = [] | |||
| # the maximum size of the toolchain cache in bytes | |||
| toolchain_cache_size = 5368709120 | |||
There was a problem hiding this comment.
please make the comment shorter, no need to document what older binaries do
Part of #2775 (splitting the OpenEmbedded/Yocto sccache-dist work into focused
PRs; replaces the closed #2750).
Rebased onto current
main(dac6c80). This revision adds a[dist] fallbackswitch, following the feature-flag suggestion in the comments.
Problem
Any remote failure during a distributed compile - a non-zero result or a dropped
output - failed the whole build instead of just the distribution, so a single
input that misbehaved remotely broke the build. The usual case is an assembler
source that
.incbins a generated file: the file is not among the shipped inputs,the remote assembler fails, and the build stops. Separately, sccache's own log
output on stderr corrupted autoconf/libtool probe output (for example a libtool
-fPICprobe reading wrapper logs off stderr).Approach
output that did not materialize) as a trigger to recompile locally.
compile.
the fallback path is diagnosable.
fallbackkey to the[dist]section of the clientconfiguration. It defaults to
true, which recompiles locally as above.fallback = falsereturns the remote result with its exit code and stderr, as0.19.0 does.
Compatibility
The key is new. Unknown keys are denied when the configuration is parsed, so an
older binary rejects a configuration that contains
fallback;leaving the key out keeps every existing configuration working. With the key absent
the behavior changes from 0.19.0: a failed remote compile is recompiled locally
instead of reported.
Test
The existing failed-compile unit test and its Docker-based dist twin keep every
assertion and run with
fallback = false. Two new tests cover both modes. On therebased branch the format check, the build, the unit tests and the Docker-based
dist tests all pass.
Evidence
A distributed build of a Linux kernel package on three build hosts with only
the wave-1 changes (this branch and #2776) and the default
fallback = truetook 562 s; the samebuild without distribution takes 881 s. Of 25,548 compile requests, 25,156 were
distributed and 392 ran locally. 4 of those were assembler sources that embed a
generated file, which fail remotely and recompile locally, as intended. The other
388 were scheduler capacity rejections, which already fell back to local
compilation before this change.
On a local client, a source that embeds a missing file exits 0 by default and
exits 1 with
fallback = false; a source with a real compile error exits 1 in bothmodes.